﻿using DWH.PP.LoopUrls.CL;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using DWH.Utils;

namespace RDTest
{
    
    
    /// <summary>
    ///This is a test class for CLSavePageAttachmentTaskTest and is intended
    ///to contain all CLSavePageAttachmentTaskTest Unit Tests
    ///</summary>
    [TestClass()]
    public class CLSavePageAttachmentTaskTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for ProcessTargetHtmlContent
        ///</summary>
        [TestMethod()]
        public void ProcessTargetHtmlContentTest()
        {
            CLSavePageAttachmentTask target = new CLSavePageAttachmentTask();             
            target.Enable = true;
            Guid newId = Guid.NewGuid();
            target.TaskName = "UT for CLSavePageAttachmentTask" + newId.ToString();

            target.ExtendData = new Dictionary<string, string>();
            target.ExtendData[DWHConstants.KEY_CONTENT_PAGE_URL_PATTERN] = @"htm_data/\d+/\d+/\d+.html";

            target.ExtendData[DWHConstants.KEY_LOOP_PAGELIST_URL_PATTERN] = "http://c1520.biz.tm/thread0806.php?fid=2&search=&page={0}";
            target.ExtendData[DWHConstants.KEY_LOOP_PAGELIST_NUMBER_START] = "1";
            target.ExtendData[DWHConstants.KEY_LOOP_PAGELIST_NUMBER_END] = "10";
            target.ExtendData[DWHConstants.KEY_WEB_ATTACHMENT_STORE_FOLDER] = "E:/WebPPAttachment/CL/";            

            target.ExtendData[DWHConstants.KEY_PAGE_ENCODING] = "gb2312";//gb2312
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT] = "//div[@class]";//<div class="tpc_content">
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT_ATTRIBUTE_NAME] = "class";
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT_ATTRIBUTE_VALUE] = @"tpc_content";

            target.Initialize();
            //target.ProcessPageContent("http://c1520.biz.tm/htm_data/2/1208/787566.html");

            target.ProcessPageContent("http://c1520.biz.tm/htm_data/7/1208/787967.html");
        }
    }
}
